package com.eastfair.auth.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 
 * </p>
 *
 * @author ligang
 * @date 2022-08-11
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "ResourceOrganizationResourceTypeEnum", description = "资源类型 #{P:项目;EXHIBITOR:展商;SPONSOR:主办;BUILDER:搭建商;COURT:主场;TRANSPORT:主运;BOOKING:场馆方;REPAST:餐饮方;other:其他-枚举")
public enum ResourceOrganizationResourceTypeEnum implements BaseEnum {

    /**
     * P="项目"
     */
    P("项目"),
    /**
     * EXHIBITOR="展商"
     */
    EXHIBITOR("展商"),
    /**
     * SPONSOR="主办"
     */
    SPONSOR("主办"),
    /**
     * BUILDER="搭建商"
     */
    BUILDER("搭建商"),
    /**
     * COURT="主场"
     */
    COURT("主场"),
    /**
     * TRANSPORT="主运"
     */
    TRANSPORT("主运"),
    /**
     * BOOKING="场馆方"
     */
    BOOKING("场馆方"),
    /**
     * REPAST="餐饮方"
     */
    REPAST("餐饮方"),
    /**
     * OTHER="其他"
     */
    OTHER("其他"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static ResourceOrganizationResourceTypeEnum match(String val, ResourceOrganizationResourceTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static ResourceOrganizationResourceTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(ResourceOrganizationResourceTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "P,EXHIBITOR,SPONSOR,BUILDER,COURT,TRANSPORT,BOOKING,REPAST,OTHER", example = "P")
    public String getCode() {
        return this.name();
    }

}
